﻿package prototype_pattern;

import java.util.ArrayList;
import java.util.Date;

/**
 * @author cbf4Life cbf4life@126.com
 * I'm glad to share my knowledge with you all.
 * 万物
 */
public class Thing implements Cloneable{
	//定义一个私有变量
	private ArrayList<String> arrayList = new ArrayList<String>();

	private String testStr;
	
	private Date date;
	
	private User user;
	
	@Override
	public Thing clone(){
		Thing thing=null;
		try {
			thing = (Thing)super.clone();	
			//除 primitive和不可变对象类型 外,都要进行clone
			this.arrayList = (ArrayList<String>)this.arrayList.clone();
			this.user = (User)this.user.clone();
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return thing;
	}
	
	//设置HashMap的值
	public void setValue(String value){
		this.arrayList.add(value);
	}
	
	//取得arrayList的值
	public ArrayList<String> getValue(){
		return this.arrayList;
	}

    public String getTestStr() {
        return testStr;
    }

    public void setTestStr(String testStr) {
        this.testStr = testStr;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }
		
	
}
